﻿USE [Spediz]
GO

CREATE TABLE [dbo].[Containers](
	[ContainerId] [int] IDENTITY(1,1) NOT NULL,
	[Sign] nchar(4) NOT NULL, 
	[Number] int NOT NULL, 
	[Checkdigit] nchar(1) NOT NULL, 
	[Type] nvarchar(6) NOT NULL,
	CONSTRAINT [PK_Container] PRIMARY KEY CLUSTERED ([ContainerId] ASC)
	WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Shippings](
	[ShippingId] [int] IDENTITY(1,1) NOT NULL, 
	[ContainerId] int NOT NULL, 
	[Type] nchar(1) NOT NULL, 
	[Seal] int NOT NULL, 
	[Weight] int NOT NULL, 
	[ToPort] nvarchar(100) NULL, 
	[FromPort] nvarchar(100) NULL, 
	[Ship] nvarchar(50) NULL, 
	[Forwarder] nvarchar(100) NULL, 
	[BoardingDate] datetime NULL, 
	[LandingDate] datetime NULL,
	CONSTRAINT [PK_Shipping] PRIMARY KEY CLUSTERED ([ShippingId] ASC)
	WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Shippings]  WITH CHECK ADD  CONSTRAINT [FK_Shippings_Containers] FOREIGN KEY([ContainerId])
REFERENCES [dbo].[Containers] ([ContainerId])
GO

ALTER TABLE [dbo].[Shippings] CHECK CONSTRAINT [FK_Shippings_Containers]
GO